package com.jcl.recruit.core.constants;

import com.jcl.core.utils.DateUtils;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName ResumeType

 * @Author yyliu
 * @Date 2018/9/20 14:10
 * @Version 1.0
 **/
public class ResumeLogType {

    // 简历添加
    public static final String TYPE_RESUME_ADD                     = "11000";
    // 简历编辑
    public static final String TYPE_RESUME_EDIT                    = "11001";
    // 评价
    public static final String TYPE_RESUME_EVALUATE                = "11002";
    // 渠道下载简历
    public static final String TYPE_RESUME_CRAWLER_DOWNLOAD        = "11003";
    // 转发
    public static final String TYPE_RESUME_SHARE                   = "11004";
    //面试
    public static final String TYPE_RESUME_INTERVIEW               = "11005";


    // 关注新增
    public static final int TYPE_ADD_ATTENTION                     = 10011;
    // 分享新增
    public static final int TYPE_ADD_SHARE                         = 10012;
    // 评价新增
    public static final int TYPE_ADD_EVALUATE                      = 10013;
    // 下载新增
    public static final int TYPE_ADD_DOWNLOAD                      = 10014;
    // 编辑
    public static final int TYPE_APPLY_EDIT                        = 10025;
    // 渠道下载简历
    public static final int TYPE_APPLY_CRAWLER_DOWNLOAD            = 10026;
    // 分享
    public static final int TYPE_APPLY_SHARE                       = 10027;
    // 简历面试
    public static final int TYPE_APPLY_INTERVIEW                   = 10031;
    // 简历评价
    public static final int TYPE_APPLY_EVALUATE                    = 10032;

    // 简历添加
    public static final String TEMPLATE_RESUME_ADD       = "用户{USERNAME}于{TIMESTAMP}新增{RESUME_NAME}的简历";
    // 简历编辑
    public static final String TEMPLATE_RESUME_EDIT      = "用户{USERNAME}于{TIMESTAMP}编辑{RESUME_NAME}的简历";
    // 简历面试
    public static final String TEMPLATE_RESUME_INTERVIEW = "用户{USERNAME}于{TIMESTAMP}对{RESUME_NAME}安排了面试";
    // 简历评价
    public static final String TEMPLATE_RESUME_EVALUATE  = "用户{USERNAME}于{TIMESTAMP}对{RESUME_NAME}的简历进行评价";

    public static final String TEMPLATE_RESUME_DOWNLOAD  = "用户{USERNAME}于{TIMESTAMP}通过渠道下载{RESUME_NAME}的简历";

    public static final String TEMPLATE_RESUME_SHARE     = "用户{USERNAME}于{TIMESTAMP}转发{RESUME_NAME}的简历";

    public static Map<Integer, String> apply_resume_type            = new HashMap<>();

    public static Map<Integer, String> apply_logTypeMap            = new HashMap<>();

    static{
        apply_resume_type.put(TYPE_ADD_ATTENTION, TYPE_RESUME_ADD);
        apply_resume_type.put(TYPE_ADD_SHARE, TYPE_RESUME_ADD);
        apply_resume_type.put(TYPE_ADD_EVALUATE, TYPE_RESUME_ADD);
        apply_resume_type.put(TYPE_ADD_DOWNLOAD, TYPE_RESUME_ADD);
        apply_resume_type.put(TYPE_APPLY_EDIT, TYPE_RESUME_EDIT);
        apply_resume_type.put(TYPE_APPLY_INTERVIEW, TYPE_RESUME_INTERVIEW);
        apply_resume_type.put(TYPE_APPLY_EVALUATE, TYPE_RESUME_EVALUATE);
        apply_resume_type.put(TYPE_APPLY_SHARE, TYPE_RESUME_SHARE);
        apply_resume_type.put(TYPE_APPLY_CRAWLER_DOWNLOAD, TYPE_RESUME_CRAWLER_DOWNLOAD);

        apply_logTypeMap.put(TYPE_ADD_ATTENTION, TEMPLATE_RESUME_ADD);
        apply_logTypeMap.put(TYPE_ADD_SHARE, TEMPLATE_RESUME_ADD);
        apply_logTypeMap.put(TYPE_ADD_EVALUATE, TEMPLATE_RESUME_ADD);
        apply_logTypeMap.put(TYPE_ADD_DOWNLOAD, TEMPLATE_RESUME_ADD);
        apply_logTypeMap.put(TYPE_APPLY_EDIT, TEMPLATE_RESUME_EDIT);
        apply_logTypeMap.put(TYPE_APPLY_INTERVIEW, TEMPLATE_RESUME_INTERVIEW);
        apply_logTypeMap.put(TYPE_APPLY_EVALUATE, TEMPLATE_RESUME_EVALUATE);
        apply_logTypeMap.put(TYPE_APPLY_SHARE, TEMPLATE_RESUME_SHARE);
        apply_logTypeMap.put(TYPE_APPLY_CRAWLER_DOWNLOAD, TEMPLATE_RESUME_DOWNLOAD);
    }

    public static String template(Integer templateId,
                                  String userName,
                                  String resumeName,
                                  String timestamp){
        if(null == templateId){
            return null;
        }
        String content = apply_logTypeMap.get(templateId);
        if(null == content){
            return null;
        }
        content = content.replaceAll("\\{USERNAME\\}", userName)
                .replaceAll("\\{TIMESTAMP\\}", resumeName)
                .replaceAll("\\{RESUME_NAME\\}", timestamp);
        return content;
    }

    public static String getResumeType(Integer category){

        return apply_resume_type.get(category);
    }

    public static String getTimestamp(){

        return DateUtils.format(new Date(), DateUtils.DATE_FORMAT_YMDHMS);
    }
}
